<?php
class qModuleInfo
{
    private $name;
    private $parent;
    private $module;
    private $submodules = array();
    
    function __construct($name, $module, $parent = null)
    {
        $this->name = $name;
        $this->parent = $parent;
        $this->module = $module;
    }
    
    public function AddSubmodule($name, $module)
    {
        $submodule = new qModuleInfo($name, $this);
        $this->submodules[] = $submodule;
    }
    
    public function Name()
    {
        return $this->name;
    }
    
    public function Module()
    {
        return $this->module;
    }
    
    public function Parent()
    {
        return $this->parent;
    }
    
    public function Parents()
    {
        if ($this->parent != null)
        {
            return $this->parent->Parents() . '/' . $this->Parent();
        }
        else
        {
            return '';
        }
    }
    
    public function SearchForSubmodule($name)
    {
        foreach ($this->submodules as $module)
        {
            if ($module->Name == $name || $module = $module->SearchForSubmodule($name))
            	return $module;
        }
        
        return false;
    }
}